package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.entity.OrderDetail;
import com.sky.entity.Orders;
import com.sky.vo.OrderStatisticsVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Author: Sabrina
 * @Date:2025/06/15/20:59
 * @Description:
 */
@Mapper
public interface AdminOrderMapper {

    /**
     * 订单搜索
     * @param dto
     * @return
     */
    Page<Orders> orderSearch(OrdersPageQueryDTO dto);

    /**
     * 根据订单id获取订单明细表的数据
     * @param id
     * @return
     */
    @Select("SELECT * FROM order_detail WHERE order_id = #{id}")
    List<OrderDetail> getOrderDetails(Long id);

    /**
     * 根据id查订单数据
     * @return
     */
    @Select("SELECT * FROM orders WHERE id = #{id}")
    Orders getOrderById(Long id);

    /**
     * 各个状态的订单数量统计
     * @return
     */
    OrderStatisticsVO getStatusCounts();

    /**
     * 取消订单
     * @param orders
     */
    void update(Orders orders);
}
